package com.jamal2362.apktool;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import com.jamal2362.apktool.util.TextUtil;
import com.jamal2362.apktool.util.TraceReader;

public class CrashActivity extends ThemedActivity
{
	@Override
	protected void init(Bundle savedInstanceState)
	{
		setContentView(R.layout.crash);
		final TraceReader reader = new TraceReader(this);
		final String log = reader.readToString();
		final TextView text = findViewById(R.id.crashTextView1);
		final Button delete = findViewById(R.id.crashButton1);
		final Button copy = findViewById(R.id.crashButton2);
		final Button send = findViewById(R.id.crashButton3);
		text.setText(log);
		delete.setOnClickListener(new OnClickListener()
			{
				@Override
				public void onClick(View p1)
				{
					deleteFile("stack.trace");
					finish();
				}
			});
		copy.setOnClickListener(new OnClickListener()
			{
				@Override
				public void onClick(View p1)
				{
					TextUtil.setClipboard(CrashActivity.this, text.getText().toString());
				}
			});
		send.setOnClickListener(new OnClickListener()
			{
				@Override
				public void onClick(View p1)
				{
					reader.sendLog();
				}
			});
	}

	@Override
	public void onBackPressed()
	{
		finish();
	}
}
